package ru.papergames.model.binsocket.packets.response
{
	import ru.papergames.model.binsocket.data.ExtByteArray;
	import ru.papergames.model.binsocket.packets.SocketResponse;
	import ru.papergames.model.vo.PlayerVO;

	public class BattleMemberListResponse extends SocketResponse
	{		
		public static const NOTIFICATION:String = 'BattleMemberListResponse';
		
		public var battleOrderId:uint;	
		public var players:Array = [];	
			
		
		public function BattleMemberListResponse(bytes:ExtByteArray)
		{
			super(bytes);
		}
		
		override protected function decode():void {
			
			battleOrderId = binaryData.readUnsignedInt();
			
			var playersCount:uint = binaryData.readUnsignedShort();
			
			while (binaryData.bytesAvailable > 0 && playersCount-- > 0) {
				var player:PlayerVO = new PlayerVO();
			
				player.teamId = binaryData.readUnsignedByte();
				player.coloreId = binaryData.readUnsignedShort();
				player.isPcPlayer = binaryData.readBoolean();
				player.playerId = binaryData.readLong();
				player.username = binaryData.readUTF();
				player.level = binaryData.readUnsignedShort()
				
				players.push(player);
			}
			
		}
		
		override public function getNotification():String {
			return NOTIFICATION;
		}
	}
}